import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

/*
 * This class represents the main UI panel
 */

public class MainPanel {
	
	JFrame frame = new JFrame("SplitSim");
	StartPanel startComponent = new StartPanel();
	ResultPanel resultComponent = new ResultPanel();
	LOIPanel lomiComponent = new LOIPanel();
	GraphPanel graphComponent = new GraphPanel();
	HelpPanel helpComponent = new HelpPanel();
	
	//constructor
	public MainPanel(){
	 frame.setSize(1000,500);
	 frame.setBackground(Color.lightGray);
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

 	 SplitSim.mainFrame=frame;
  
     // Create the menu bar
     JMenuBar menuBar = new JMenuBar();

     // Create a menu
     JMenuItem menuStart = new JMenuItem("Start");
     menuBar.add(menuStart);
     
     JMenuItem menuGraph = new JMenuItem("Result Graph");
     menuBar.add(menuGraph);
     
     JMenuItem menuResults = new JMenuItem("Result Data");
     menuBar.add(menuResults);
     
     JMenuItem menuLOMI= new JMenuItem("Level of Maximum Interest");
     menuBar.add(menuLOMI);
     
     JMenuItem menuHelp = new JMenuItem("Help");
     menuBar.add(menuHelp);
     
     
     //actions
     //ActionListener menuActions = new ActionListener();
     menuStart.addActionListener(
		new ActionListener(){
			public void actionPerformed(ActionEvent e){
				frame.setContentPane(startComponent);
				startComponent.paintComponent(frame.getGraphics());
				frame.pack();
			}
		}
	 );
     menuGraph.addActionListener(
		new ActionListener(){
			public void actionPerformed(ActionEvent e){
				frame.setContentPane(graphComponent);
				graphComponent.paintComponent(frame.getGraphics());
				frame.pack();
			}
		}
	 );
     menuResults.addActionListener(
		new ActionListener(){
			public void actionPerformed(ActionEvent e){
				frame.setContentPane(resultComponent);
				resultComponent.refreshResults();
				frame.pack();
			}
		}
	 );
     
     menuLOMI.addActionListener(
		new ActionListener(){
			public void actionPerformed(ActionEvent e){
				frame.setContentPane(lomiComponent);
				lomiComponent.refreshResults();
				frame.pack();
			}
		}
	 );
     
     
     menuHelp.addActionListener(
		new ActionListener(){
			public void actionPerformed(ActionEvent e){
				frame.setContentPane(helpComponent);
				frame.pack();
			}
		}
	 );
     
     // Install the menu bar in the frame
     frame.setJMenuBar(menuBar);
     
     frame.setContentPane(startComponent);
     
     frame.setVisible(true);
	}
}
